package fa7.socialcode.service.impl;

import java.util.Date;
import java.util.List;

import fa7.socialcode.dao.ExampleDao;
import fa7.socialcode.model.Example;
import fa7.socialcode.service.ExampleManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "exampleManager")
public class ExampleManagerImpl implements ExampleManager {
    @Autowired
    ExampleDao exampleDao;

    public void setExampleDao(ExampleDao dao) {
        this.exampleDao = dao;
    }

    public List getExamples() {
        return exampleDao.getExamples();
    }

    public Example getExample(String exampleId) {
        return exampleDao.getExample(Long.valueOf(exampleId));
    }

    public void saveExample(Example example) {
        
        example.setDate(new Date());
        exampleDao.saveExample(example);
    }

    public void removeExample(String exampleId) {
        exampleDao.removeExample(Long.valueOf(exampleId));
    }
}
